home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Examples / MergeTest / main.m next >
Encoding:
Text File  |  1995-07-11  |  1.7 KB  |  52 lines

  1. //        Written by Don Yacktman Copyright (c) 1995 by Don Yacktman.
  2. //                Version 1.0.  All rights reserved.
  3. //
  4. //        This notice may not be removed from this source code.
  5. //
  6. //    This object is included in the MiscKit by permission from the author
  7. //    and its use is governed by the MiscKit license, found in the file
  8. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  9. //    for a list of all applicable permissions and restrictions.
  10. //    
  11.  
  12. #import <misckit/misckit.h>
  13. #import <misckit/miscmerge.h>
  14.  
  15. void main()
  16. {
  17.     List *output; int i;
  18.  
  19.     // Set up the file names for the template and data files
  20.     MiscString *templateFile = [MiscString newWithString:"test1.template"];
  21.     MiscString *dataFile = [MiscString newWithString:"test1.data"];
  22.  
  23.     // A way to read the data file, independent of the merges
  24.     // (But it turns an ascii file into a data structure the
  25.     // merge kit can deal with.)
  26.     MiscRecordParser *recparser = [[MiscRecordParser alloc] init];
  27.  
  28.     // Basic objects required for a merge:
  29.     MiscMergeTemplate *template = [[MiscMergeTemplate alloc] init];
  30.     MiscMergeDriver *merger = [[MiscMergeDriver alloc] init];
  31.  
  32.     // Load the files from disk
  33.     [template parseFromFileNamed:templateFile];
  34.     [recparser loadFromFileNamed:dataFile];
  35.  
  36.     // set up the merge
  37.     [merger setTemplate:template];
  38.     [merger setMergeData:[recparser records]];
  39.  
  40.     // do the merge
  41.     output = [merger doMerge:nil];
  42.     
  43.     // Print out the results
  44.     for (i=0; i<[output count]; i++) {
  45.         printf("--------------------------------------------------------\n");
  46.         printf("%s\n", [[output objectAt:i] stringValue]);
  47.     }
  48.     printf("--------------------------------------------------------\n");
  49.     // If we weren't exiting, we'd go to the trouble of freeing everything
  50.     // here to avoid memory leaks.
  51.     exit(0);
  52. }